import type { AxiosRequestConfig } from 'axios';

export interface GeneratreOption {}

export interface ParameterBody {
  in: string;
  name: string;
  description: string;
  required: boolean;
  schema: Schema;
}

export interface DefinitionBasic {
  type: 'integer' | 'string';
  title?: string;
  description?: string;
  format?: DefinitionType;
  example?: any;
}

export interface DefinitionRef extends DefinitionBasic {
  $ref: string;
  originalRef: string;
}

export interface DefinitionObject extends DefinitionBasic {
  type: 'object';
  required: string[];
  properties: Record<string, DefinitionType>;
}

export interface DefinitionArray extends DefinitionBasic {
  type: 'array';
  uniqueItems?: boolean;
  items: DefinitionType;
}
export type DefinitionType = DefinitionBasic | DefinitionRef | DefinitionObject;

export interface Parameter {
  name: string;
  in: 'query' | 'body' | 'path';
  type?: string;
  description?: string;
  required?: boolean;
  schema?: DefinitionRef;
}
export interface PathsItemData {
  tags: string[];
  summary: string;
  description: string;
  operationId: string;
  consumes: string[];
  produces: string[];
  security: Security[];
  'x-order': string;
  parameters?: Parameter[];
  responses: { [key: string]: DefinitionType };
}

export type RequestMethod = 'post' | 'get' | 'delete' | 'put';

export type Paths = Record<string, PathsItemData>;

export interface Info {
  description: string;
  version: string;
  title: string;
  contact: Contact;
  license: License;
}

export interface License {
  name: string;
}

export interface Contact {
  name: string;
  url: string;
  email: string;
}

export interface SwaggerData {
  swagger: string;
  info: Info;
  host: string;
  tags: { name: string; 'x-order': string }[];
  paths: Record<string, Paths>;
  securityDefinitions: SecurityDefinitions;
  definitions: { [key: string]: DefinitionType };
}

export interface Swagger2JsOption {
  import: string;
  requestName: string;
  /** 存放的相对路径 */
  path: string;
  swagger: AxiosRequestConfig;
}
